﻿<Application x:Class="Application"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:InteropTest"
    StartupUri="IPWindow.xaml">
    <Application.Resources>


        <Style TargetType="{x:Type ToolTip}" x:Key="NetToolTipStyle">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="StaysOpen" Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToolTip}">
                        <Border BorderBrush="DarkOliveGreen"
                                        CornerRadius="8"
                                        HorizontalAlignment="Stretch"
                                        VerticalAlignment="Stretch"
                                        Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}"
                                        BorderThickness="0.75">

                            <Grid Margin="8"
                                  Background="Transparent">

                                <Grid.Resources>

                                    <Style TargetType="{x:Type TextBlock}" x:Key="Heading">
                                        <Setter Property="Foreground"
                                                        Value="{DynamicResource {x:Static SystemColors.InfoTextBrushKey}}" />
                                        <Setter Property="FontFamily"
                                                        Value="Segoe UI" />
                                        <Setter Property="FontSize"
                                                        Value="12" />
                                        <Setter Property="FontWeight"
                                                        Value="SemiBold" />
                                        <Setter Property="Margin"
                                                        Value="8,4,8,2" />
                                    </Style>

                                    <Style TargetType="{x:Type TextBlock}" x:Key="Content">
                                        <Setter Property="Foreground"
                                                        Value="{DynamicResource {x:Static SystemColors.InfoTextBrushKey}}" />
                                        <Setter Property="FontFamily"
                                                        Value="Lucida Console" />
                                        <Setter Property="FontSize"
                                                        Value="12" />
                                        <Setter Property="FontWeight"
                                                        Value="Light" />
                                        <Setter Property="Margin"
                                                        Value="24,2,8,2" />
                                    </Style>
                                </Grid.Resources>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>

                                <Image Source="{Binding DeviceIcon}"
                                               RenderOptions.BitmapScalingMode="HighQuality"
                                               VerticalAlignment="Top"
                                               HorizontalAlignment="Center"
                                               Margin="8,8,0,8"
                                               SnapsToDevicePixels="True"
                                               Stretch="Uniform"
                                               Width="48"
                                               Height="48"
                                               Grid.Column="0" />


                                <StackPanel Grid.Column="1">

                                    <TextBlock Style="{StaticResource Heading}" Text="Friendly Name:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.FriendlyName}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Description:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.Description}" />


                                    <TextBlock Style="{StaticResource Heading}" Text="Device Install Date:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.InstallDate}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Bus Type:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.BusType}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Class Name:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.ClassName}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Class Description:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.ClassDescription}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="PDO Name:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.PDOName}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Device Instance Id:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.InstanceId}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Device Path:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DeviceInfo.DevicePath}" />
                                </StackPanel>
                            </Grid>
                            <Border.BitmapEffect>
                                <DropShadowBitmapEffect Color="Gray"  Softness="0.5" ShadowDepth="4" Opacity="0.7" Direction="-45" />
                            </Border.BitmapEffect>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style TargetType="{x:Type ToolTip}" x:Key="DeviceToolTipStyle">
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="StaysOpen" Value="True" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ToolTip}">
                        <Border BorderBrush="DarkOliveGreen"
                                        CornerRadius="8"
                                        HorizontalAlignment="Stretch"
                                        VerticalAlignment="Stretch"
                                        Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}"
                                        BorderThickness="0.75">

                            <Grid Margin="8"
                                  Background="Transparent">

                                <Grid.Resources>

                                    <Style TargetType="{x:Type TextBlock}" x:Key="Heading">
                                        <Setter Property="Foreground"
                                                        Value="{DynamicResource {x:Static SystemColors.InfoTextBrushKey}}" />
                                        <Setter Property="FontFamily"
                                                        Value="Segoe UI" />
                                        <Setter Property="FontSize"
                                                        Value="12" />
                                        <Setter Property="FontWeight"
                                                        Value="SemiBold" />
                                        <Setter Property="Margin"
                                                        Value="8,4,8,2" />
                                    </Style>

                                    <Style TargetType="{x:Type TextBlock}" x:Key="Content">
                                        <Setter Property="Foreground"
                                                        Value="{DynamicResource {x:Static SystemColors.InfoTextBrushKey}}" />
                                        <Setter Property="FontFamily"
                                                        Value="Lucida Console" />
                                        <Setter Property="FontSize"
                                                        Value="12" />
                                        <Setter Property="FontWeight"
                                                        Value="Light" />
                                        <Setter Property="Margin"
                                                        Value="24,2,8,2" />
                                    </Style>
                                </Grid.Resources>

                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition />
                                </Grid.ColumnDefinitions>

                                <Image Source="{Binding DeviceIcon}"
                                               RenderOptions.BitmapScalingMode="HighQuality"
                                               VerticalAlignment="Top"
                                               HorizontalAlignment="Center"
                                               Margin="8,8,0,8"
                                               SnapsToDevicePixels="True"
                                               Stretch="Uniform"
                                               Width="48"
                                               Height="48"
                                               Grid.Column="0" />


                                <StackPanel Grid.Column="1">

                                    <TextBlock Style="{StaticResource Heading}" Text="Friendly Name:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding FriendlyName}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Description:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding Description}" />


                                    <TextBlock Style="{StaticResource Heading}" Text="Device Install Date:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding InstallDate}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Bus Type:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding BusType}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Class Name:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding ClassName}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Class Description:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding ClassDescription}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="PDO Name:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding PDOName}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Device Instance Id:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding InstanceId}" />

                                    <TextBlock Style="{StaticResource Heading}" Text="Device Path:" />
                                    <TextBlock Style="{StaticResource Content}"
                                                       Text="{Binding DevicePath}" />
                                </StackPanel>
                            </Grid>
                            <Border.BitmapEffect>
                                <DropShadowBitmapEffect Color="Gray"  Softness="0.5" ShadowDepth="4" Opacity="0.7" Direction="-45" />
                            </Border.BitmapEffect>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <ToolTip Style="{StaticResource DeviceToolTipStyle}" x:Key="DeviceToolTip" />

        <ToolTip Style="{StaticResource NetToolTipStyle}" x:Key="NetToolTip" />

        <SolidColorBrush x:Key="SmoothCharcoalDark" Color="#FF646158" />
        <SolidColorBrush x:Key="SmoothCharcoal" Color="#FF7A766D" />
        <SolidColorBrush x:Key="SmoothCharcoalLight" Color="#FF9E998E" />
 
        <Style TargetType="{x:Type ListViewItem}">
            <Setter Property="TextBlock.FontFamily" Value="Segoe UI" />
            <Setter Property="TextBlock.FontSize" Value="12" />
            <Setter Property="Height" Value="48" />
        </Style>

        <LinearGradientBrush x:Key="PrgGradient" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="White" Offset="1"/>
            <GradientStop Color="#FF6599F3" Offset="0"/>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="HWGradient" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="White" Offset="1"/>
            <GradientStop Color="#FFF3CC65" Offset="0"/>
        </LinearGradientBrush>

       
        <LinearGradientBrush x:Key="AppGradient" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="White" Offset="1"/>
            <GradientStop Color="#FFA5FFC6" Offset="0"/>
        </LinearGradientBrush>

        <LinearGradientBrush x:Key="FSGradient" EndPoint="0.5,1" StartPoint="0.5,0">
            <GradientStop Color="White" Offset="1"/>
            <GradientStop Color="#FF86C0F0" Offset="0"/>
        </LinearGradientBrush>

        <DataTemplate x:Key="ImgCell">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="64" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>

                </Grid.RowDefinitions>

                <Image Source="{Binding DeviceIcon}"
                       RenderOptions.BitmapScalingMode="HighQuality"
                       SnapsToDevicePixels="True"
                       MinWidth="32"
                       Stretch="None"
                       Grid.Column="0" 
                       Grid.Row="0"
                       ToolTip="{StaticResource NetToolTip}"
                       ToolTipService.ShowDuration="15000"
                       Grid.RowSpan="2"/>

                <TextBlock Text="{Binding Description}"
                           VerticalAlignment="Center"   
                           Grid.Column="1" 
                           Grid.Row="0"/>

                <TextBlock Text="{Binding FirstUnicastAddress.Next}"
                           VerticalAlignment="Center"   
                           FontSize="8"
                           Grid.Column="1"
                           Grid.Row="1"/>

            </Grid>

        </DataTemplate>

        <DataTemplate x:Key="NetCell">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="64" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>

                </Grid.RowDefinitions>

                <Image Source="{Binding DeviceIcon}"
                       MinWidth="32"
                       Stretch="None"
                       Grid.Column="0" 
                       Grid.Row="0"
                       Grid.RowSpan="2"/>

                <TextBlock Text="{Binding Description}"
                           VerticalAlignment="Center"   
                           Grid.Column="1" 
                           Grid.Row="0"/>

                <TextBlock Text="{Binding DeviceInfo.Manufacturer}"
                           VerticalAlignment="Center"   
                           FontSize="8"
                           Grid.Column="1"
                           Grid.Row="1"/>

            </Grid>

        </DataTemplate>

        <DataTemplate x:Key="LibraryCell">
            <Grid Margin="2,4,2,4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="64" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Image Source="{Binding DefaultImage}"
                       RenderOptions.BitmapScalingMode="HighQuality"
                       SnapsToDevicePixels="True"
                       Stretch="Uniform"
                       Width="48"
                       Height="48"
                       Grid.Column="0" 
                       Grid.Row="0"
                       Grid.RowSpan="2"/>

                <TextBlock Text="{Binding Description}"
                           VerticalAlignment="Center"   
                           FontSize="12"
                           Grid.Column="1" 
                           Grid.Row="0"/>

                <TextBlock Text="{Binding PreferredHandler.UIName}"
                           VerticalAlignment="Center"   
                           FontSize="10"
                           Grid.Column="1" 
                           Grid.Row="1"/>

                <TextBlock Text="{Binding Extension}"
                           VerticalAlignment="Center"   
                           FontSize="8"
                           Grid.Column="1" 
                           Grid.Row="2"/>

            </Grid>

        </DataTemplate>

        <DataTemplate x:Key="LibraryCellSmall">
            <Grid Margin="2,4,2,4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="32" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Image Source="{Binding DefaultImage}"
                       RenderOptions.BitmapScalingMode="HighQuality"
                       SnapsToDevicePixels="True"
                       Stretch="Uniform"
                       Width="24"
                       Height="24"
                       Grid.Column="0" 
                       Grid.Row="0"
                       Grid.RowSpan="2"/>

                <TextBlock Text="{Binding Description}"
                           VerticalAlignment="Center"   
                           FontSize="10"
                           Grid.Column="1" 
                           Grid.Row="0"/>

            </Grid>

        </DataTemplate>

        <DataTemplate x:Key="ProgramCell">
            <Grid Margin="2,4,2,4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="64" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Image Source="{Binding Image}"
                       RenderOptions.BitmapScalingMode="HighQuality"
                       VerticalAlignment="Top"
                       SnapsToDevicePixels="True"
                       Stretch="Uniform"
                       Width="48"
                       Height="48"
                       Grid.Column="0" 
                       Grid.Row="0"
                       Grid.RowSpan="2"/>

                <TextBlock Text="{Binding UIName}"
                           VerticalAlignment="Center"   
                           FontSize="12"
                           Grid.Column="1" 
                           Grid.Row="0"/>

                <Grid Grid.Row="1"
                      Grid.Column="1">

                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>

                    <TextBlock Text="{Binding Preferred}"
                           VerticalAlignment="Center"   
                           FontSize="10"
                           Grid.Column="0" 
                           Grid.Row="0"/>

                    <ItemsControl
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch"
                        ItemsSource="{Binding AssocList}"
                        Grid.Row="1"
                        Grid.Column="0"
                        ItemTemplate="{DynamicResource LibraryCellSmall}"
                        Background="{x:Null}">

                    </ItemsControl>

                </Grid>
            </Grid>

        </DataTemplate>

        <DataTemplate x:Key="ProgramTreeCell">
            <Grid Margin="2,4,2,4">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="64" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Image Source="{Binding Image}"
                       RenderOptions.BitmapScalingMode="HighQuality"
                       VerticalAlignment="Top"
                       SnapsToDevicePixels="True"
                       Stretch="Uniform"
                       Width="48"
                       Height="48"
                       Grid.Column="0" 
                       Grid.Row="0"
                       Grid.RowSpan="2"/>

                <TextBlock Text="{Binding UIName}"
                           VerticalAlignment="Center"   
                           FontSize="12"
                           Grid.Column="1" 
                           Grid.Row="0"/>

                <Grid Grid.Row="1"
                      Grid.Column="1">

                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>

                    <TextBlock Text="{Binding Preferred}"
                           VerticalAlignment="Center"   
                           FontSize="10"
                           Grid.Column="0" 
                           Grid.Row="0"/>

                </Grid>
            </Grid>

        </DataTemplate>

    </Application.Resources>
</Application>
